package org.mspring.mlog.web.security.interceptors;

import java.io.IOException;

import javax.servlet.ServletException;

import org.mspring.mlog.web.security.interceptors.handlers.AbstractFailureHandler;
import org.springframework.security.web.FilterInvocation;

/**
 * 安全验证拦截器的抽象类
 * 
 * @author Gao Youbo
 * @since 2013年7月11日
 */
public abstract class AbstractSecurityInterceptor {

    /**
     * 执行安全过滤
     * 
     * @param fi
     * @throws IOException
     * @throws ServletException
     * @return 标记是否验证成功
     */
    public abstract boolean exec(FilterInvocation fi) throws IOException, ServletException;

    /**
     * 用于获取验证失败后的处理方式
     * 
     * @param fi
     */
    public AbstractFailureHandler getFailureHandler(FilterInvocation fi) {
        return getNativeFailureHandler(fi);
    }

    /**
     * 提供给子类实现
     * 
     * @param fi
     * @return
     */
    protected abstract AbstractFailureHandler getNativeFailureHandler(FilterInvocation fi);
}
